cc.Class({
            extends: cc.Component,

            properties: {
                sheep: {
                    default: null,
                    type: cc.Node
                },
                // canvas: cc.Node,
            },

            // use this for initialization
            onLoad() {
                var self = this;
                // set initial move direction
                this.turnRight();
                self.canvas.on(cc.Node.EventType.MOUSE_DOWN, function(event) {
                            this.turnLeft();
                        },
                        //add keyboard input listener to call turnLeft and turnRight
                        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
                        // cc.systemEvent.on(cc.systemEvent.EventType.MOUSE_DOWN, this.onMouseDown, this);
                    },
                    onMouseDown(event) {
                        this.turnLeft();
                    },
                    onDestroy() {
                        cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
                        // cc.systemEvent.off(cc.systemEvent.EventType.MOUSE_DOWN, this.onMouseDown, this);
                    },

                    onKeyDown(event) {
                        var macro = cc.macro;
                        switch (event.keyCode) {
                            case macro.KEY.a:
                            case macro.KEY.left:
                                console.log('turn left');
                                this.turnLeft();
                                break;
                            case macro.KEY.d:
                            case macro.KEY.right:
                                console.log('turn right');
                                this.turnRight();
                                break;
                        }
                    },

                    // called every frame
                    update(dt) {
                        this.sheep.x += this.speed * dt;
                    },

                    turnLeft() {
                        this.speed = -100;
                        this.sheep.scaleX = 1;
                    },

                    turnRight() {
                        this.speed = 100;
                        this.sheep.scaleX = -1;
                    }
            });